<template>
  <div class="order">
    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片区域 -->
    <el-card>
      <!-- 搜索框 -->
      <el-row>
        <el-col :span="8">
          <el-input placeholder="请输入内容" v-model="searchInput">
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <!-- 订单列表 -->
      <el-table :data="orderList" style="width: 100%" border stripe>
        <el-table-column label="#" type="index" width="50px"> </el-table-column>
        <el-table-column prop="order_number" label="订单编号">
        </el-table-column>
        <el-table-column prop="order_price" label="订单价格" width="90px">
        </el-table-column>
        <el-table-column label="是否付款" width="90px">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.pay_status === '0'" type="danger"
              >未付款</el-tag
            >
            <el-tag v-else type="success">已付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货" width="90px">
        </el-table-column>
        <el-table-column label="下单时间" width="220px">
          <template slot-scope="scope">
            {{ scope.row.create_time | dateFormat }}
          </template>
        </el-table-column>
        <el-table-column label="操作" width="150px">
          <template>
            <el-button
              type="primary"
              icon="el-icon-edit"
              size="mini"
              @click="showLocationDialog"
            ></el-button>
            <el-button
              type="success"
              icon="el-icon-location"
              size="mini"
              @click="showProgressDialog"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>

    <!-- 修改地址弹出框 -->

    <el-dialog
      @close="locationCascaderClose"
      title="修改地址"
      :visible.sync="isLocationDialog"
      width="50%"
    >
      <!-- form表单 -->
      <el-form
        :model="locationForm"
        :rules="locationFormRules"
        ref="locationFormRef"
        label-width="100px"
      >
        <el-form-item label="省市区/县" prop="location1">
          <!-- 级联选择器 -->
          <el-cascader
            v-model="locationForm.location1"
            :options="cityData"
            :props="{ expandTrigger: 'hover' }"
          ></el-cascader>
        </el-form-item>
        <el-form-item label="详细地址" prop="location2">
          <el-input v-model="locationForm.location2"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="isLocationDialog = false">取 消</el-button>
        <el-button type="primary" @click="isLocationDialog = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>

    <!-- 物流进度对话框 -->

    <el-dialog
      title="物流进度"
      :visible.sync="isProgressDialog"
      width="50%"
    >
      <span>这是一段信息</span>
    </el-dialog>
  </div>
</template>

<script>
import cityData from "../../assets/js/citydata";
import { getOrderList } from "../../network/order/order";
import { getProcess } from "../../network/order/order";
export default {
  name: "",
  data() {
    return {
      // 搜索框双向绑定
      searchInput: "",
      //   查询数据参数
      queryInfo: {
        query: "",
        pagenum: 1,
        pagesize: 10,
      },
      // 数据总数
      total: null,
      // 订单列表
      orderList: [],
      //修改地址弹出框
      //是否弹出对话框
      isLocationDialog: false,
      //修改地址对话框表单
      locationForm: {
        location1: [],
        location2: "",
      },
      //表单验证规则
      locationFormRules: {
        location1: [{ required: true, message: "请选择地区", trigger: "blur" }],
        location2: [
          { required: true, message: "请输入具体地址", trigger: "blur" },
        ],
      },
      // 城镇区域级联选择器数据
      cityData: cityData,
      //物流进度弹出框
      //   是否弹出物流进度对话框
      isProgressDialog: false,
    };
  },
  created() {
    this.getOrderList();
  },
  methods: {
    //   获取商品数据列表
    async getOrderList() {
      const res = await getOrderList(this.queryInfo);
      if (res.meta.status != 200) return this.$message.error(res.meta.msg);
      this.total = res.data.total;
      this.orderList = res.data.goods;
      console.log(this.total);
      console.log(this.orderList);
    },
    // ---------------------------------------------------分割线
    // 修改地址对话框
    // 弹出修改地址对话框
    showLocationDialog() {
      this.isLocationDialog = true;
    },
    //关闭对话框清空表单
    locationCascaderClose() {
      this.$refs.locationFormRef.resetFields();
    },

    // ---------------------------------------------------分割线
    // 物流进度对话框
    // 弹出修改地址对话框
   async showProgressDialog(){
        // 获取物流信息
        const res = await getProcess()
        console.log(res);
        this.isProgressDialog=true
    }
  },
};
</script>

<style  scoped>
.el-cascader {
  width: 100%;
}
</style>
